package com.sbmoon.db;

import java.util.ResourceBundle;

import com.sbmoon.*;
import com.sbmoon.util.BundleUtil;

public class DbFactoryOld extends ComLib {

	public final ResourceBundle getRouteSystemBundle() {
		String bundleFileName = "bundle/BDL000_ROUTE_SYS" ;
		boolean useCache = false;

		ResourceBundle bundle = BundleUtil.getBundle( bundleFileName , useCache );

		return bundle;
	}

	public synchronized DatabaseOracle getOracleDb() {
		if ( true ) {
			ResourceBundle routeSysBundle = this.getRouteSystemBundle();
			String bundleName = routeSysBundle.getString( "DB_BUNDLE_NAME" );
			if( true ) {
				this.debug( "DB_BUNDLE_NAME: " + bundleName );
			}
			DatabaseOracle db = DatabaseOracle.getDatabaseOracleFromBundle(bundleName, true );

			return db;

		} else if (ORACLE_DB == null) {
			ResourceBundle routeSysBundle = this.getRouteSystemBundle();
			String bundleName = routeSysBundle.getString( "DB_BUNDLE_NAME" );
			if( true ) {
				this.debug( "DB_BUNDLE_NAME: " + bundleName );
			}
			DatabaseOracle db = DatabaseOracle.getDatabaseOracleFromBundle(bundleName, true );
			ORACLE_DB = db;
		}

		return ORACLE_DB;
	}

	private DbFactoryOld() {
	}

	public static DbFactoryOld getDbFactory() {
		return dbFactory;
	}

	private DatabaseOracle ORACLE_DB;

	private static final DbFactoryOld dbFactory = new DbFactoryOld();

}
